package com.woniu.apartment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.woniu.apartment.domain.ApartmentExt;
import com.woniu.apartment.service.IApartmentExtService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公寓详情Controller
 * 
 * @author yy
 * @date 2023-04-03
 */
@RestController
@RequestMapping("/apartment/tbapartmentext")
@Api("公寓详情管理")
public class ApartmentExtController extends BaseController
{
    @Autowired
    private IApartmentExtService apartmentExtService;

    /**
     * 查询公寓详情列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartmentext:list')")
    @GetMapping("/list")
    @ApiOperation("公寓详情分页查询")
    public TableDataInfo list(ApartmentExt apartmentExt)
    {
        startPage();
        List<ApartmentExt> list = apartmentExtService.selectApartmentExtList(apartmentExt);
        return getDataTable(list);
    }

    /**
     * 导出公寓详情列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartmentext:export')")
    @Log(title = "公寓详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("公寓详情导出")
    public void export(HttpServletResponse response, ApartmentExt apartmentExt)
    {
        List<ApartmentExt> list = apartmentExtService.selectApartmentExtList(apartmentExt);
        ExcelUtil<ApartmentExt> util = new ExcelUtil<ApartmentExt>(ApartmentExt.class);
        util.exportExcel(response, list, "公寓详情数据");
    }

    /**
     * 获取公寓详情详细信息
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartmentext:query')")
    @GetMapping(value = "/{apartmentId}")
    @ApiOperation("根据主键查询公寓详情")
    @ApiImplicitParam(name = "apartmentIds", value = "用户ID", required = true, dataType = "Long")
    public AjaxResult getInfo(@PathVariable("apartmentId") Long apartmentId)
    {
        return success(apartmentExtService.selectApartmentExtByApartmentId(apartmentId));
    }

    /**
     * 新增公寓详情
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartmentext:add')")
    @Log(title = "公寓详情", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("添加公寓详情")
    public AjaxResult add(@RequestBody ApartmentExt apartmentExt)
    {
        return toAjax(apartmentExtService.insertApartmentExt(apartmentExt));
    }

    /**
     * 修改公寓详情
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartmentext:edit')")
    @Log(title = "公寓详情", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("更新公寓详情")
    public AjaxResult edit(@RequestBody ApartmentExt apartmentExt)
    {
        return toAjax(apartmentExtService.updateApartmentExt(apartmentExt));
    }

    /**
     * 删除公寓详情
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartmentext:remove')")
    @Log(title = "公寓详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{apartmentIds}")
    @ApiOperation("删除公寓详情")
    @ApiImplicitParam(name = "apartmentIds", value = "主键数组", required = true, dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] apartmentIds)
    {
        return toAjax(apartmentExtService.deleteApartmentExtByApartmentIds(apartmentIds));
    }
}
